<style type="text/css">
.labelhide .layui-form-label{display:none;}
.layui-form-label{width:90px;}
.layui-input-block {margin-left:120px;}
form{margin-right:20px;margin-top:10px;}
.layui-form-item{margin-bottom:10px;}
.logic .layui-form-label{padding:9px 3px;width:70px;}
.logic .layui-input-block{margin-left:86px;}
.layui-laydate-header{padding:0px 0px 0px 0px;}
.layui-laydate-list{padding:0px;}
.layui-laydate-content{padding:0px;}
</style>
<form class="layui-form" action="{:url()}" method="post" id="editForm">
<table width="100%" border="0">
    <tr>
        <td colspan="2">
            <table width="100%" border="0">
              <tr>
                <td>{:FormExt::setInputInline(false)}
      {:FormExt::input('配置项名称', 'label_name',$labelInfo['label_name'], '单行输入', 'required', 'lay-verify="required"')}</td>
                <td width="" style="padding-left:15px;padding-bottom:10px;">
                    {:FormExt::select('* 展示地址','address_id',$labelInfo['address_id'], $board_address,'','','lay-filter="addAdress"')}
                </td>
              </tr>
            </table>
        </td>
    </tr>
    <!--<tr>
        <td colspan="2"><table width="100%" border="0">
              <tr>
                <td>{:FormExt::select('所属菜单', 'storehouse_id', '', $storehouseKV, '', '', 'lay-filter="storehouse-id"')}</td>
                <td>{:FormExt::select('二级菜单', 'menu_id', '', [], '', '')}</td>
              </tr>
            </table>    </td>
    </tr>-->
    <tr>
        <td colspan="2"><div style="color:red;border-top:1px solid #ccc;padding-top:10px;margin-bottom:30px;">第二步：配置环节搜索条件</div></td>
    </tr>
    <tr>
        <td colspan="2">
        	<table width="100%" border="0">
              <tr>
                <td width="120" align="right">搜索物料状态：</td>
                <td><div id="search_data_status" class="layui-form-item"></div></td>

              </tr>
            </table>        </td>

    </tr>
    <tr>
        <td colspan="2">
            <table width="100%" border="0" style="margin-top: 20px;">
                <tr>
                    <td width="120" align="right">订单状态：</td>
                    <td>  {:Form::select('order_status', $labelInfo['order_status'], ['' => '请选择', 1=>'未采购', 2=>'已采购', 3=>'已裁床', 4=>'已车缝', 5=>'已后整', 6=>'已出货', 7=>'已完成', 99=>'已废弃', 999=>'MES废除'], '', '')}
                    </td>
                    <td width="230">
                        <div class="logic">
                            {:FormExt::select('断码情况','break_code_status',$labelInfo['break_code_status'], [''=>'请选择','1'=>'正常','2'=>'将断码','3'=>'已断码'],'','')}
                        </div></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td colspan="2">
            <table width="100%" border="0"  style="margin-top: 20px;">
                <tr>
                    <td width="120" align="right" style="font-size:12px;">剩余出货天数：<br>（货期-当前时间）</td>
                    <td><div id="shipment_day"></div>
                    </td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td colspan="2">
            <table width="100%" border="0"  style="margin-top: 20px;">
                <tr>
                    <td width="120" align="right">搜索工厂：</td>
                    <td><div id="factory_ids"></div></td>
                    <!--<td width="120"><div style="padding-left:15px;">
                    <input name="empty_factory_order" type="checkbox" value="1" {if ($empty_factory_order==1)}checked="checked"{/if} lay-skin="primary" title="包括未分厂" /></div></td>-->
                </tr>
            </table>        </td>
    </tr>

    <tr>
        <td colspan="2">
        	<table width="100%" border="0"  style="margin-top: 20px;">
              <tr>
                <td width="120" align="right">搜索小组：</td>
                <td><div id="group_ids"></div></td>
                <!--<td width="120"><div style="padding-left:15px;">
                <input name="empty_factory_order" type="checkbox" value="1" {if ($empty_factory_order==1)}checked="checked"{/if} lay-skin="primary" title="包括未分厂" /></div></td>-->
              </tr>
            </table>        </td>
    </tr>

    <tr>
    	<td colspan="2" style="padding:4px 0px;">
        <table width="100%" border="0">
          <tr>
            <td width="120" align="right">显示物料类型：</td>
            <td>
            {:Form::select('search_materal_type',$search_materal_type, [0 => '请选择', 1=>'面料', 2=>'铺料'])}</td>
            <td>
            <div class="layui-inline">
				<label class="layui-form-label" style="width:46px;">单类</label>
				<div class="layui-input-inline">
					{:Form::select('order_type',$labelInfo['order_type'], [''=>'全部','normal'=>'返单','new'=>'首单','emergent'=>'紧急单','my_first'=>'奖励(第一次做不含尾货)','my_return_first'=>'初返'], '', '')}
				</div>
			</div>
            </td>
          </tr>
        </table>        </td>
    </tr>

    <tr>
        <td height="80" colspan="2" style=""><div style="color:red;border-top:1px solid #ccc;padding-top:3px;">第三步：配置时间/关系搜索条件</div></td>
    </tr>

    <tr>
        <td colspan="2">
            <table width="100%" border="0">
                <tr>
                    <td width="120" align="right">开始时间：</td>
                    <td><input type="text" valign="middle" name="search_start_time"  placeholder="yyyy-MM-dd HH:mm:ss"  id="search_start_time" value="{if (empty($labelInfo['search_start_time']))}{/if}{:$labelInfo['search_start_time']}" size="8" style="height:26px;width: 150px;"   />
                       <span style="color:#BC751B">（选择时间后，将只展示再次时间后的被选中物料、订单状态的时间的订单）</span>
                    </td>
                    <td width="250"><div class="logic">{:FormExt::select('状态关系','m_status_logic',$labelInfo['m_status_logic'], [''=>'请选择','or'=>'符合一项即展示', 'and'=>'符合全部才展示'])}</div></td>
                </tr>
            </table>
        </td>

    </tr>
    <tr>
        <td width="120" align="right" valign="middle" >*搜索截至时间：</td>
        <td style="line-height:26px;padding-top:12px;"><input type="text" valign="middle" name="search_end_time" autocomplete="off" id="search_end_time" value="{if (empty($labelInfo['search_end_time']))}18:00:00{/if}{:$labelInfo['search_end_time']}" size="8" style="height:26px;"  lay-verify="required" />
            <input type="radio" name="search_history" value="" title="无" {if ($labelInfo['search_history']=='')}checked=""{/if}>
            <input type="radio" name="search_history" value="today" title="只统计当天" {if ($labelInfo['search_history']=='today')}checked=""{/if}>
            <input type="radio" name="search_history" value="yestoday" title="只统计前一天" {if ($labelInfo['search_history']=='yestoday')}checked=""{/if}>
            <input type="radio" name="search_history" value="all" title="统计全部" {if ($labelInfo['search_history']=='all' )} checked=""{/if}>
            <div style="color:#BC751B;text-align:left;">备注：如已设开始时间，则不支持选择时间段，可设置截止时间</div>
        </td>
    </tr>

    <tr>
        <td height="41" colspan="2" style=""><div style="color:red;border-top:1px solid #ccc;padding-top:3px;">第四步：配置可访问帐号</div></td>
    </tr>
    <!--<tr>
        <td colspan="2">
        	<table width="100%" border="0">
              <tr>
                <td width="120" align="right">可访问角色：</td>
                <td><div id="visit_role_ids"></div></td>
              </tr>
            </table>        </td>
    </tr>-->
    <tr>
        <td colspan="2">
        	<table width="100%" border="0" style="margin-bottom: 160px;margin-top:20px;">
              <tr>
                <td width="120" align="right">*可访问帐号：</td>
                <td>
                	<table width="100%" border="0" cellspacing="8" >
                      <tr>
                        <!--<td align="left" width="200" class="labelhide">{:Form::select('storehouse_id', '', $role_names, '', '', 'lay-filter="storehouse-id"')}</td>-->
                        <td><div id="visit_admin_ids" style="margin-left:15px;"></div></td>
                      </tr>
                    </table>                </td>
              </tr>
            </table>        </td>
    </tr>
</table>
<div class="pop-bottom-bar">
    	<input type="hidden" class="field-id" name="id" value="{:$labelInfo['id']}">
        <!--<button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit">提交保存</button>-->
        <button type="submit" id="btnrejects" class="layui-btn mimo-tab layui-btn-normal" lay-submit="" tabindex="101" lay-filter="rejects">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

<script id="onclickChangeDeliverNumTpl" type="text/html">
    <form class="layui-form"  method="post" id="editForm22">
        <input type="hidden" name="ids_str" class="ids_strs" value="">
        <input type="hidden" name="type" class="is_type_outIn" value="">

        <div class="layui-inline">
            <div class="layui-form-item">
                <label class="layui-form-label">订单号：</label>
                <div class="layui-input-block">
                    <input type="text" name="client_ordernum"  value=""  placeholder="请输入订单号" class="layui-input client_ordernum_select">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">码数：</label>
                <div class="layui-input-block">
                    <input type="text" name="size_name" value=""  placeholder="请输入码数" class="layui-input size_name_select">
                </div>
            </div>
        </div>

        <div class="pop-bottom-bar">
            <input type="hidden" class="field-id" name="id">
            <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit3" >确定</button>
            <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
        </div>
    </form>

</script>
{include file="system@block/layui" /}
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js"></script>
<script>
    var factoryAll= JSON.parse('{:json_encode($factoryAll)}');
    var formData = {:json_encode($formData)};
	var storeshelfMap = {:json_encode($storeshelfMap)};
    layui.use(['form', 'func','laydate','colorpicker','laytpl'], function() {
        var $ = layui.jquery, form = layui.form,laydate=layui.laydate,colorpicker = layui.colorpicker,laytpl = layui.laytpl;
        layui.func.assign(formData);

        var factory_all = xmSelect.render({
            el: '#group_ids',
            name:'group_ids',
            autoRow: true,
            filterable: true,
            tree: {
                show: true,
                showFolderIcon: true,
                showLine: true,
                indent: 20,
                expandedKeys: [ -3 ],
            },
            toolbar: {
                show: true,
                list: ['ALL', 'REVERSE', 'CLEAR']
            },
            data: function(){
                return factoryAll;
            }
        })
        var demo1 = xmSelect.render({
            el: '#factory_ids',
            name:'factory_ids',
            autoRow: true,
            filterable: true,
            toolbar: {
                show: true,
                list: ['ALL', 'CLEAR']
            },
            data: {:json_encode($factorylist)}
    })
		laydate.render({
		  elem: '#search_end_time'
		  ,type: 'time'
		});
        laydate.render({
            elem: '#search_start_time'
            ,type: 'datetime'
        });
		colorpicker.render({
			elem: '.label_color'
			,color:'{:$bgcolor}'
			,predefine: true
			,colors: ['#c2c2c2','#FF5722','#009688','#5FB878','#393D49','#1E9FFF','#FFB800','#01AAED','#2F4056']
			,done: function(color){
				$("#label_color").val(color);
			}
		});
		// 货仓下拉切换
    	form.on('select(storehouse-id)', function(data){
    		var optionArr = storeshelfMap[data.value];
    		var option = '';
    		for(var i in optionArr) {
    			option += '<option value="'+i+'">'+optionArr[i]+'</option>';
    		}
    		$("select[name=menu_id] option").remove();
    		$('select[name=menu_id]').append(option);
    		form.render();
    	});
		//监听提交
		form.on('submit(rejects)', function(data){
			var datalist = data.field;
            if(datalist.search_data_status !='' && datalist.order_status !=''){
                layer.msg('搜索物料状态 和 订单状态不能同时选择！', {icon: 2,anim: 6});
                return false;
            }
			if(datalist.address_id==''){
				layer.msg('展示地址必填', {icon: 2,anim: 6});
				return false;
			}
            if(datalist.label_name==''){
                layer.msg('标签名字必填', {icon: 2,anim: 6});
                return false;
            }
			if(datalist.factory_ids=='' && datalist.group_ids=='' ){
				layer.msg('搜索工厂、小组，请填写其中一个！', {icon: 2,anim: 6});
				return false;
			}
            if(datalist.factory_ids !='' && datalist.group_ids !='' ){
                layer.msg('搜索工厂、小组，只能选一个！', {icon: 2,anim: 6});
                return false;
            }
			if(datalist.visit_admin_ids==''){
				layer.msg('可访问帐号必填', {icon: 2,anim: 6});
				return false;
			}
            if(datalist.search_start_time !='' && datalist.search_history !=''){
                layer.msg('开始时间和 选择时间段 不能同时选择！ ', {icon: 2,anim: 6});
                return false;
            }

			$.ajax({
			   type: "POST",
			   url: "{:url('boardList')}?use_action=edit_search_label",
			   data: data.field,
			   dataType:"json",
			   success: function(res){
				  if (res.code == 1) {
					 layer.msg(res.msg, {icon: 1,time:600,end:function(){
						parent.layui.layer.closeAll();
						parent.location.reload();
					 }});
				  } else {
					 layer.msg(res.msg, {icon: 2,anim: 6,time:4000});
				  }
			   }
			});
			return false;
		});
        //监听下来
        form.on('select(addAdress)', function(data){
          if(data.value==-100){
              layerStockOutIn = layer.open({
                  type: 2
                  ,area: ['500px','400px']
                  ,offset: 'auto'
                  ,shade:[0.3, '#393D49']
                  ,anim: 5
                  ,title:'新增展示地址'
                  ,skin:'layui-layer-molv'
                  ,shadeClose:true
                  ,content: "{:url('addAddress')}?type="+1
                  ,btn1:function(index2, layero){
                  }
                  ,btn2:function(index, layero){
                      // 按钮2的逻辑
                  }
                  ,end:function () {
                  }
              });
          }

        })

		var demo1 = xmSelect.render({
			el: '#search_data_status',
			name:'search_data_status',
			autoRow: true,
			filterable: true,
			data: {:json_encode($materialStatus)}
		})

		var demo4 = xmSelect.render({
			el: '#visit_role_ids',
			name:'visit_role_ids',
			autoRow: true,
			filterable: true,
			data: {:json_encode($visit_role_ids)}
		})
		var demo3 = xmSelect.render({
			el: '#visit_admin_ids',
			name:'visit_admin_ids',
			autoRow: true,
			filterable: true,
			data: {:json_encode($visit_admin_ids)}
		});
        var demo5 = xmSelect.render({
            el: '#shipment_day',
            name:'shipment_day',
            autoRow: true,
            filterable: true,
            toolbar: {
                show: true,
                list: ['ALL', 'CLEAR']
            },
            data: {:json_encode($shipment_day)}
       });
    });
</script>